import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ProFlowVO, ProFlowForm, ProFlowQuery } from '@/api/project/plan/flow/types';

/**
 * 查询项目流程列表（分页）
 * @param query
 * @returns {*}
 */
export const pageListProFlow = (query?: ProFlowQuery): AxiosPromise<any> => {
  return request({
    url: '/pro/flow/page',
    method: 'get',
    params: query
  });
};

/**
 * 查询项目流程列表（非分页）
 * @param query
 * @returns {*}
 */
export const listProFlow = (query?: ProFlowQuery): AxiosPromise<ProFlowVO[]> => {
  return request({
    url: '/pro/flow/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询项目流程列表（用于项目流程回显查询使用）
 * @param query
 * @returns {*}
 */
export const listProFlowForQuery = (query?: ProFlowQuery): AxiosPromise<ProFlowVO[]> => {
  return request({
    url: '/pro/flow/listForQuery',
    method: 'get',
    params: query
  });
};

/**
 * 查询项目流程详细
 * @param id
 */
export const getProFlow = (id: string | number): AxiosPromise<ProFlowVO> => {
  return request({
    url: '/pro/flow/' + id,
    method: 'get'
  });
};

/**
 * 新增项目流程
 * @param data
 */
export const addProFlow = (data: ProFlowForm) => {
  return request({
    url: '/pro/flow',
    method: 'post',
    data: data
  });
};

/**
 * 修改项目流程
 * @param data
 */
export const updateProFlow = (data: ProFlowForm) => {
  return request({
    url: '/pro/flow',
    method: 'put',
    data: data
  });
};

/**
 * 删除项目流程
 * @param id
 */
export const delProFlow = (id: string | number | Array<string | number>) => {
  return request({
    url: '/pro/flow/' + id,
    method: 'delete'
  });
};

/**
 * 批量保存项目流程
 * @param data
 */
export const batchSaveProFlow = (data: ProFlowForm[]) => {
  return request({
    url: '/pro/flow',
    method: 'post',
    data
  });
};


/**
 * 获取项目信息详细信息+流程信息（用于审核回显）
 * @param id 项目ID
 */
export const getProFlowAuditInfo = (id: string | number): AxiosPromise<any> => {
  return request({
    url: `/pro/flow/auditInfo/${id}`,
    method: 'get'
  });
};
